<template>
   <div id="app" v-cloak>
      <BaseHeader2 title="管理员中心"></BaseHeader2>
      <div class="main_con clearfix">
         <div class="left_menu_con clearfix">
            <h3>
               <router-link to="/my_center">管理界面</router-link>
            </h3>
            <table cellspacing="0" cellpadding="5">
               <tr v-for="(type, index) in typeList">
                  <td width="80%" align="center"><el-tag size="medium"><a :href="`/adv_add?type_id=${type.id}`"> · {{ type.title }} </a></el-tag></td>
                  <td></td>
                  <td width="20%"> <el-button @click="delType(index, type.id)" type="danger" size="mini"
                          icon="el-icon-delete" circle> </el-button></td>
               </tr>
            </table>
            <h3><a href="/type_add" class="active">·> 类型添加 <·</a></h3>
         </div>
         <div class="right_content clearfix">
            <router-view></router-view>
         </div>
      </div>
      <BaseBodyer></BaseBodyer>
   </div>
</template>

<script>
   import BaseHeader2 from "../Header/BaseHeader2";
   import BaseBodyer from "../Header/BaseBodyer";

   export default {
      name: "MyIndex",
      components: {
         BaseHeader2,
         BaseBodyer,
      },
      data() {
         return {
            typeList: [],
         }
      },
      created() {
         this.$axios({
            url: 'adminapp/type/',
         }).then(resp => {
            this.typeList = resp.data
         })
      },
      methods: {
         delType(index, id) {
            console.log(index, id);
            this.$axios({
               url: 'adminapp/type/',
               method: 'DELETE',
               params: {
                  type_id: id
               }
            }).then(resp => {
               alert(resp.data.msg);
               if (resp.data.code == 200) {
                  this.typeList.splice(index, 1)
               }
            })
         },
      },
      computed: {},
      filters: {},
      watch: {},
   }
</script>

<style scoped>
/*.btr{*/
/*   border-bottom: 1px solid #ddd;*/
/*   margin-bottom: 20px;*/
/*}*/
</style>
